﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DemoGo
{
    public partial class FrmMain : Form
    {
        private Game game;
        public FrmMain()
        {
            InitializeComponent();
        }

        private void panelRight_Paint(object sender, PaintEventArgs e)
        {
            if (game != null)
            {
                game.Draw(e.Graphics, this.gameArea.Size);
            }
        }


        private void gameArea_Load(object sender, EventArgs e)
        {
            //初始化
            game = new Game();
            
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            game = new Game();
            game.gamechanged += Game_gamechanged;
        }

        private void Game_gamechanged()
        {
            if (game!=null)
            {
                gameArea.Invalidate();
            }
        }

        private void panelRight_Paint_1(object sender, PaintEventArgs e)
        {

        }

        private void gameArea_MouseDown(object sender, MouseEventArgs e)
        {
            if (game != null)
            {
                //调用game的鼠标点击处理程序
                game.MouseDown(e.Location, this.gameArea.Size);
                //重绘游戏区域
                this.gameArea.Invalidate();
                //处理输赢
            }
        }
    }
}
